//
//  YHSearchResultTableCell.m
//  FAKER
//
//  Created by dllo on 15/11/8.
//  Copyright © 2015年 YHLai. All rights reserved.
//

#import "YHSearchResultTableCell.h"
#import "FitHeader.h"

@implementation YHSearchResultTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}

- (void)createViews
{
    _webView = [[BaseClassWebView alloc] init];
    _webView.backgroundColor = [UIColor whiteColor];
    _webView.scrollView.scrollEnabled = NO;
    _webView.scrollView.showsHorizontalScrollIndicator = NO;
    _webView.delegate = self;
    [CONTENT_VIEW addSubview:_webView];
    
//    _postTimeLabel = [[UILabel alloc] init];
//    _postTimeLabel.font = [UIFont systemFontOfSize:13];
//    _postTimeLabel.textColor = [UIColor grayColor];
//    [CONTENT_VIEW addSubview:_postTimeLabel];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
//    _webView.frame = CGRectMake(0, 0, self.contentView.WIDTH, self.contentView.HEIGHT + 1);
//    _webView.frame = CGRectMake(0, 0, self.contentView.WIDTH, 80);
    _webView.frame = self.contentView.frame;
//    _postTimeLabel.frame = CGRectMake(0, _webView.HEIGHT, SCREEN_WIDTH, 30);
}

#pragma mark - webView协议方法
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    //webView上显示的html的高度
//    CGFloat htmlHeight = [[_webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] doubleValue];
    //webView的高度
//    CGFloat htmlHeight = [[_webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"] doubleValue];
//    NSLog(@"%f", htmlHeight);
    
//    [_webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '90%'"];
//    [_webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'gray'"];
//    [_webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='#2E2E2E'"];
}

#pragma mark - 重写属性set
- (void)setHtmlString:(NSString *)htmlString
{
//    [_webView loadHTMLString:htmlString baseURL:nil];
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:htmlString]]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
